/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package it.polimi.games.epkb.entityClasses;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author plebani
 */
@Entity
@Table(name = "system_action_on_component")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "SystemActionOnComponent.findAll", query = "SELECT s FROM SystemActionOnComponent s"),
    @NamedQuery(name = "SystemActionOnComponent.findByIdSystemAction", query = "SELECT s FROM SystemActionOnComponent s WHERE s.systemActionOnComponentPK.idSystemAction = :idSystemAction"),
    @NamedQuery(name = "SystemActionOnComponent.findByIdComponent", query = "SELECT s FROM SystemActionOnComponent s WHERE s.systemActionOnComponentPK.idComponent = :idComponent"),
    @NamedQuery(name = "SystemActionOnComponent.findByEnabled", query = "SELECT s FROM SystemActionOnComponent s WHERE s.enabled = :enabled")})
public class SystemActionOnComponent implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected SystemActionOnComponentPK systemActionOnComponentPK;
    @Column(name = "Enabled")
    private Boolean enabled;
    @JoinColumn(name = "Id_Component", referencedColumnName = "ID", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Component component;
    @JoinColumn(name = "Id_SystemAction", referencedColumnName = "ID", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private SystemAction systemAction;

    public SystemActionOnComponent() {
    }

    public SystemActionOnComponent(SystemActionOnComponentPK systemActionOnComponentPK) {
        this.systemActionOnComponentPK = systemActionOnComponentPK;
    }

    public SystemActionOnComponent(String idSystemAction, String idComponent) {
        this.systemActionOnComponentPK = new SystemActionOnComponentPK(idSystemAction, idComponent);
    }

    public SystemActionOnComponentPK getSystemActionOnComponentPK() {
        return systemActionOnComponentPK;
    }

    public void setSystemActionOnComponentPK(SystemActionOnComponentPK systemActionOnComponentPK) {
        this.systemActionOnComponentPK = systemActionOnComponentPK;
    }

    public Boolean getEnabled() {
        return enabled;
    }

    public void setEnabled(Boolean enabled) {
        this.enabled = enabled;
    }

    public Component getComponent() {
        return component;
    }

    public void setComponent(Component component) {
        this.component = component;
    }

    public SystemAction getSystemAction() {
        return systemAction;
    }

    public void setSystemAction(SystemAction systemAction) {
        this.systemAction = systemAction;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (systemActionOnComponentPK != null ? systemActionOnComponentPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof SystemActionOnComponent)) {
            return false;
        }
        SystemActionOnComponent other = (SystemActionOnComponent) object;
        if ((this.systemActionOnComponentPK == null && other.systemActionOnComponentPK != null) || (this.systemActionOnComponentPK != null && !this.systemActionOnComponentPK.equals(other.systemActionOnComponentPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "it.polimi.games.epkb.entityClasses.SystemActionOnComponent[ systemActionOnComponentPK=" + systemActionOnComponentPK + " ]";
    }
    
}
